import pytest
from tools.parse_class_time import parse_class_time


@pytest.mark.parametrize("input_str, expected", [
    ("二[6-8节]", (2, 6, 8)),
    ("三[5-5节]", (3, 5, 5)),
    ("六[2-5节]", (6, 2, 5)),
], ids=["常规节次", "单节课", "周末课程"])
def test_parse_class_time(input_str, expected):
    day, start, end = parse_class_time(input_str)
    assert (day, start, end) == expected
    assert isinstance(day, int)
    assert isinstance(start, int)
    assert isinstance(end, int)


def test_invalid_cases():
    # 测试错误格式
    with pytest.raises(ValueError):
        parse_class_time("日[1_2节]")  # 非法星期字符

    # 测试类型错误
    with pytest.raises(ValueError):
        parse_class_time("二[6-八节]")  # 非数字节次